<template>
  <div class="placard" v-if="model">
    <block v-for="(item, index) in model.images" :key="index">
      <image class="show" :src="item.image" mode="widthFix" lazy-load="true" @click="handleRouter(item)"> </image>
    </block>
  </div>
</template>
<script>
import * as PlacardActions from '@/api/placard'
export default {
  data () {
    return {
      model: null
    }
  },
  onLoad (query) {
    wx.showNavigationBarLoading()
    this.fetchModel(query.id)
  },
  methods: {
    handleRouter (item) {
      if (!item.target) return
      wx.navigateTo({ url: '../product/detail?id=' + item.target })
    },
    fetchModel (id) {
      PlacardActions.show(id).then(data => {
        this.model = data
        wx.setNavigationBarTitle({ title: this.model.title })
        wx.hideLoading()
        wx.hideNavigationBarLoading()
      }).catch(err => console.log(err.msg))
    }
  }
}
</script>
<style lang="less" scoped>
.placard {
.show {
  width: 100%;
  margin-bottom: -12rpx;
}
}

</style>